package cn.ryanpenn.bigdata.hadoop.wordcount;

import org.apache.hadoop.util.ToolRunner;

/**
 * 单次计数 WordCount App 程序入口
 *
 * @author Ryan
 */
public class App {

    // Usage:
    // 0.环境 参考 docs/Readme.txt 文档的介绍
    // 1.启动 >%HADOOP_HOME%\sbin\start-all.cmd  (mac: $HADOOP_HOME/sbin/start-all.sh)
    //   资源管理GUI: http://localhost:8088/
    //   节点管理GUI: http://localhost:50070/
    // 2.打包 >mvn clean package
    // 3.创建 >fs -mkdir /user
    //   创建 >fs -mkdir /user/wordcount
    //   创建 >fs -mkdir /user/wordcount/input
    //   创建 >fs -mkdir /user/wordcount/output
    // 4.删除 >hadoop fs -rm /user/wordcount/input/words.txt (可选，删除之前的文件)
    //   上传 >hadoop fs -put docs/words.txt /user/wordcount/input/words.txt
    // 5.运行 >hadoop jar target/wordCountJob-with-dependencies.jar /user/wordcount/input/words.txt /user/wordcount/output
    // 6.观察 >hadoop fs -cat /user/wordcount/output/part-r-00000
    // 7.结束 >%HADOOP_HOME%\sbin\stop-all.cmd  (mac: $HADOOP_HOME/sbin/stop-all.sh)

    public static void main(String[] args) throws Exception {
        System.setProperty("hadoop.home.dir", System.getenv("HADOOP_HOME"));
        int exitCode = ToolRunner.run(new WordCountDriver(), args);
        System.exit(exitCode);
    }
}
